{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 30,
   "metadata": {},
   "outputs": [],
   "source": [
    "import urllib.request\n",
    "import os\n",
    "\n",
    "data_file_path = \"data/titanic_train.csv\"\n",
    "\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 31,
   "metadata": {},
   "outputs": [],
   "source": [
    "import pandas as pd \n",
    "titanic_data = pd.read_csv(data_file_path)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 32,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>PassengerId</th>\n",
       "      <th>Survived</th>\n",
       "      <th>Pclass</th>\n",
       "      <th>Age</th>\n",
       "      <th>SibSp</th>\n",
       "      <th>Parch</th>\n",
       "      <th>Fare</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>count</th>\n",
       "      <td>891.000000</td>\n",
       "      <td>891.000000</td>\n",
       "      <td>891.000000</td>\n",
       "      <td>714.000000</td>\n",
       "      <td>891.000000</td>\n",
       "      <td>891.000000</td>\n",
       "      <td>891.000000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>mean</th>\n",
       "      <td>446.000000</td>\n",
       "      <td>0.383838</td>\n",
       "      <td>2.308642</td>\n",
       "      <td>29.699118</td>\n",
       "      <td>0.523008</td>\n",
       "      <td>0.381594</td>\n",
       "      <td>32.204208</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>std</th>\n",
       "      <td>257.353842</td>\n",
       "      <td>0.486592</td>\n",
       "      <td>0.836071</td>\n",
       "      <td>14.526497</td>\n",
       "      <td>1.102743</td>\n",
       "      <td>0.806057</td>\n",
       "      <td>49.693429</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>min</th>\n",
       "      <td>1.000000</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>1.000000</td>\n",
       "      <td>0.420000</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.000000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>25%</th>\n",
       "      <td>223.500000</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>2.000000</td>\n",
       "      <td>20.125000</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>7.910400</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>50%</th>\n",
       "      <td>446.000000</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>3.000000</td>\n",
       "      <td>28.000000</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>14.454200</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>75%</th>\n",
       "      <td>668.500000</td>\n",
       "      <td>1.000000</td>\n",
       "      <td>3.000000</td>\n",
       "      <td>38.000000</td>\n",
       "      <td>1.000000</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>31.000000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>max</th>\n",
       "      <td>891.000000</td>\n",
       "      <td>1.000000</td>\n",
       "      <td>3.000000</td>\n",
       "      <td>80.000000</td>\n",
       "      <td>8.000000</td>\n",
       "      <td>6.000000</td>\n",
       "      <td>512.329200</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "       PassengerId    Survived      Pclass  ...       SibSp       Parch        Fare\n",
       "count   891.000000  891.000000  891.000000  ...  891.000000  891.000000  891.000000\n",
       "mean    446.000000    0.383838    2.308642  ...    0.523008    0.381594   32.204208\n",
       "std     257.353842    0.486592    0.836071  ...    1.102743    0.806057   49.693429\n",
       "min       1.000000    0.000000    1.000000  ...    0.000000    0.000000    0.000000\n",
       "25%     223.500000    0.000000    2.000000  ...    0.000000    0.000000    7.910400\n",
       "50%     446.000000    0.000000    3.000000  ...    0.000000    0.000000   14.454200\n",
       "75%     668.500000    1.000000    3.000000  ...    1.000000    0.000000   31.000000\n",
       "max     891.000000    1.000000    3.000000  ...    8.000000    6.000000  512.329200\n",
       "\n",
       "[8 rows x 7 columns]"
      ]
     },
     "execution_count": 32,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "titanic_data.describe()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 33,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>PassengerId</th>\n",
       "      <th>Survived</th>\n",
       "      <th>Pclass</th>\n",
       "      <th>Name</th>\n",
       "      <th>Sex</th>\n",
       "      <th>Age</th>\n",
       "      <th>SibSp</th>\n",
       "      <th>Parch</th>\n",
       "      <th>Ticket</th>\n",
       "      <th>Fare</th>\n",
       "      <th>Cabin</th>\n",
       "      <th>Embarked</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>3</td>\n",
       "      <td>Braund, Mr. Owen Harris</td>\n",
       "      <td>male</td>\n",
       "      <td>22.0</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>A/5 21171</td>\n",
       "      <td>7.2500</td>\n",
       "      <td>NaN</td>\n",
       "      <td>S</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>2</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>Cumings, Mrs. John Bradley (Florence Briggs Th...</td>\n",
       "      <td>female</td>\n",
       "      <td>38.0</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>PC 17599</td>\n",
       "      <td>71.2833</td>\n",
       "      <td>C85</td>\n",
       "      <td>C</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>3</td>\n",
       "      <td>1</td>\n",
       "      <td>3</td>\n",
       "      <td>Heikkinen, Miss. Laina</td>\n",
       "      <td>female</td>\n",
       "      <td>26.0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>STON/O2. 3101282</td>\n",
       "      <td>7.9250</td>\n",
       "      <td>NaN</td>\n",
       "      <td>S</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>4</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>Futrelle, Mrs. Jacques Heath (Lily May Peel)</td>\n",
       "      <td>female</td>\n",
       "      <td>35.0</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>113803</td>\n",
       "      <td>53.1000</td>\n",
       "      <td>C123</td>\n",
       "      <td>S</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>5</td>\n",
       "      <td>0</td>\n",
       "      <td>3</td>\n",
       "      <td>Allen, Mr. William Henry</td>\n",
       "      <td>male</td>\n",
       "      <td>35.0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>373450</td>\n",
       "      <td>8.0500</td>\n",
       "      <td>NaN</td>\n",
       "      <td>S</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "   PassengerId  Survived  Pclass  ...     Fare Cabin  Embarked\n",
       "0            1         0       3  ...   7.2500   NaN         S\n",
       "1            2         1       1  ...  71.2833   C85         C\n",
       "2            3         1       3  ...   7.9250   NaN         S\n",
       "3            4         1       1  ...  53.1000  C123         S\n",
       "4            5         0       3  ...   8.0500   NaN         S\n",
       "\n",
       "[5 rows x 12 columns]"
      ]
     },
     "execution_count": 33,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "titanic_data.head()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 34,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>Survived</th>\n",
       "      <th>Pclass</th>\n",
       "      <th>Sex</th>\n",
       "      <th>Age</th>\n",
       "      <th>SibSp</th>\n",
       "      <th>Parch</th>\n",
       "      <th>Fare</th>\n",
       "      <th>Embarked</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>0</td>\n",
       "      <td>3</td>\n",
       "      <td>male</td>\n",
       "      <td>22.0</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>7.2500</td>\n",
       "      <td>S</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>female</td>\n",
       "      <td>38.0</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>71.2833</td>\n",
       "      <td>C</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>1</td>\n",
       "      <td>3</td>\n",
       "      <td>female</td>\n",
       "      <td>26.0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>7.9250</td>\n",
       "      <td>S</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>female</td>\n",
       "      <td>35.0</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>53.1000</td>\n",
       "      <td>S</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>0</td>\n",
       "      <td>3</td>\n",
       "      <td>male</td>\n",
       "      <td>35.0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>8.0500</td>\n",
       "      <td>S</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "   Survived  Pclass     Sex   Age  SibSp  Parch     Fare Embarked\n",
       "0         0       3    male  22.0      1      0   7.2500        S\n",
       "1         1       1  female  38.0      1      0  71.2833        C\n",
       "2         1       3  female  26.0      0      0   7.9250        S\n",
       "3         1       1  female  35.0      1      0  53.1000        S\n",
       "4         0       3    male  35.0      0      0   8.0500        S"
      ]
     },
     "execution_count": 34,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "selected_cols = [\"Survived\",\"Pclass\",\"Sex\",\"Age\",\"SibSp\",\"Parch\",\"Fare\",\"Embarked\"]\n",
    "selected_data = titanic_data[selected_cols]\n",
    "selected_data.head()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 35,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "Survived    False\n",
       "Pclass      False\n",
       "Sex         False\n",
       "Age          True\n",
       "SibSp       False\n",
       "Parch       False\n",
       "Fare        False\n",
       "Embarked     True\n",
       "dtype: bool"
      ]
     },
     "execution_count": 35,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "selected_data.isnull().any()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 36,
   "metadata": {},
   "outputs": [],
   "source": [
    "mean = selected_data[\"Age\"].mean()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 37,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "29.69911764705882"
      ]
     },
     "execution_count": 37,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "mean"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 38,
   "metadata": {},
   "outputs": [
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "c:\\users\\inspur\\appdata\\local\\programs\\python\\python37\\lib\\site-packages\\ipykernel_launcher.py:1: SettingWithCopyWarning: \n",
      "A value is trying to be set on a copy of a slice from a DataFrame.\n",
      "Try using .loc[row_indexer,col_indexer] = value instead\n",
      "\n",
      "See the caveats in the documentation: https://pandas.pydata.org/pandas-docs/stable/user_guide/indexing.html#returning-a-view-versus-a-copy\n",
      "  \"\"\"Entry point for launching an IPython kernel.\n"
     ]
    }
   ],
   "source": [
    "selected_data[\"Age\"] = selected_data[\"Age\"].fillna(mean)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 39,
   "metadata": {},
   "outputs": [
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "c:\\users\\inspur\\appdata\\local\\programs\\python\\python37\\lib\\site-packages\\ipykernel_launcher.py:1: SettingWithCopyWarning: \n",
      "A value is trying to be set on a copy of a slice from a DataFrame.\n",
      "Try using .loc[row_indexer,col_indexer] = value instead\n",
      "\n",
      "See the caveats in the documentation: https://pandas.pydata.org/pandas-docs/stable/user_guide/indexing.html#returning-a-view-versus-a-copy\n",
      "  \"\"\"Entry point for launching an IPython kernel.\n",
      "c:\\users\\inspur\\appdata\\local\\programs\\python\\python37\\lib\\site-packages\\ipykernel_launcher.py:2: SettingWithCopyWarning: \n",
      "A value is trying to be set on a copy of a slice from a DataFrame.\n",
      "Try using .loc[row_indexer,col_indexer] = value instead\n",
      "\n",
      "See the caveats in the documentation: https://pandas.pydata.org/pandas-docs/stable/user_guide/indexing.html#returning-a-view-versus-a-copy\n",
      "  \n",
      "c:\\users\\inspur\\appdata\\local\\programs\\python\\python37\\lib\\site-packages\\ipykernel_launcher.py:3: SettingWithCopyWarning: \n",
      "A value is trying to be set on a copy of a slice from a DataFrame.\n",
      "Try using .loc[row_indexer,col_indexer] = value instead\n",
      "\n",
      "See the caveats in the documentation: https://pandas.pydata.org/pandas-docs/stable/user_guide/indexing.html#returning-a-view-versus-a-copy\n",
      "  This is separate from the ipykernel package so we can avoid doing imports until\n"
     ]
    }
   ],
   "source": [
    "selected_data[\"Embarked\"] = selected_data[\"Embarked\"].fillna(\"S\")\n",
    "selected_data[\"Embarked\"] = selected_data[\"Embarked\"].map({\"C\":0,\"Q\":1,\"S\":2}).astype(int)\n",
    "selected_data[\"Sex\"] = selected_data[\"Sex\"].map({\"female\":0,\"male\":1})"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 40,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>Survived</th>\n",
       "      <th>Pclass</th>\n",
       "      <th>Sex</th>\n",
       "      <th>Age</th>\n",
       "      <th>SibSp</th>\n",
       "      <th>Parch</th>\n",
       "      <th>Fare</th>\n",
       "      <th>Embarked</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>0</td>\n",
       "      <td>3</td>\n",
       "      <td>1</td>\n",
       "      <td>22.0</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>7.2500</td>\n",
       "      <td>2</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>38.0</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>71.2833</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>1</td>\n",
       "      <td>3</td>\n",
       "      <td>0</td>\n",
       "      <td>26.0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>7.9250</td>\n",
       "      <td>2</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>35.0</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>53.1000</td>\n",
       "      <td>2</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>0</td>\n",
       "      <td>3</td>\n",
       "      <td>1</td>\n",
       "      <td>35.0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>8.0500</td>\n",
       "      <td>2</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "   Survived  Pclass  Sex   Age  SibSp  Parch     Fare  Embarked\n",
       "0         0       3    1  22.0      1      0   7.2500         2\n",
       "1         1       1    0  38.0      1      0  71.2833         0\n",
       "2         1       3    0  26.0      0      0   7.9250         2\n",
       "3         1       1    0  35.0      1      0  53.1000         2\n",
       "4         0       3    1  35.0      0      0   8.0500         2"
      ]
     },
     "execution_count": 40,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "selected_data.head()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 41,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>Survived</th>\n",
       "      <th>Pclass</th>\n",
       "      <th>Sex</th>\n",
       "      <th>Age</th>\n",
       "      <th>SibSp</th>\n",
       "      <th>Parch</th>\n",
       "      <th>Fare</th>\n",
       "      <th>Embarked</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>count</th>\n",
       "      <td>891.000000</td>\n",
       "      <td>891.000000</td>\n",
       "      <td>891.000000</td>\n",
       "      <td>891.000000</td>\n",
       "      <td>891.000000</td>\n",
       "      <td>891.000000</td>\n",
       "      <td>891.000000</td>\n",
       "      <td>891.000000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>mean</th>\n",
       "      <td>0.383838</td>\n",
       "      <td>2.308642</td>\n",
       "      <td>0.647587</td>\n",
       "      <td>29.699118</td>\n",
       "      <td>0.523008</td>\n",
       "      <td>0.381594</td>\n",
       "      <td>32.204208</td>\n",
       "      <td>1.536476</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>std</th>\n",
       "      <td>0.486592</td>\n",
       "      <td>0.836071</td>\n",
       "      <td>0.477990</td>\n",
       "      <td>13.002015</td>\n",
       "      <td>1.102743</td>\n",
       "      <td>0.806057</td>\n",
       "      <td>49.693429</td>\n",
       "      <td>0.791503</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>min</th>\n",
       "      <td>0.000000</td>\n",
       "      <td>1.000000</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.420000</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.000000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>25%</th>\n",
       "      <td>0.000000</td>\n",
       "      <td>2.000000</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>22.000000</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>7.910400</td>\n",
       "      <td>1.000000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>50%</th>\n",
       "      <td>0.000000</td>\n",
       "      <td>3.000000</td>\n",
       "      <td>1.000000</td>\n",
       "      <td>29.699118</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>14.454200</td>\n",
       "      <td>2.000000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>75%</th>\n",
       "      <td>1.000000</td>\n",
       "      <td>3.000000</td>\n",
       "      <td>1.000000</td>\n",
       "      <td>35.000000</td>\n",
       "      <td>1.000000</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>31.000000</td>\n",
       "      <td>2.000000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>max</th>\n",
       "      <td>1.000000</td>\n",
       "      <td>3.000000</td>\n",
       "      <td>1.000000</td>\n",
       "      <td>80.000000</td>\n",
       "      <td>8.000000</td>\n",
       "      <td>6.000000</td>\n",
       "      <td>512.329200</td>\n",
       "      <td>2.000000</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "         Survived      Pclass         Sex  ...       Parch        Fare    Embarked\n",
       "count  891.000000  891.000000  891.000000  ...  891.000000  891.000000  891.000000\n",
       "mean     0.383838    2.308642    0.647587  ...    0.381594   32.204208    1.536476\n",
       "std      0.486592    0.836071    0.477990  ...    0.806057   49.693429    0.791503\n",
       "min      0.000000    1.000000    0.000000  ...    0.000000    0.000000    0.000000\n",
       "25%      0.000000    2.000000    0.000000  ...    0.000000    7.910400    1.000000\n",
       "50%      0.000000    3.000000    1.000000  ...    0.000000   14.454200    2.000000\n",
       "75%      1.000000    3.000000    1.000000  ...    0.000000   31.000000    2.000000\n",
       "max      1.000000    3.000000    1.000000  ...    6.000000  512.329200    2.000000\n",
       "\n",
       "[8 rows x 8 columns]"
      ]
     },
     "execution_count": 41,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "selected_data.describe()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 42,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "array([[ 0.    ,  3.    ,  1.    , ...,  0.    ,  7.25  ,  2.    ],\n",
       "       [ 1.    ,  1.    ,  0.    , ...,  0.    , 71.2833,  0.    ],\n",
       "       [ 1.    ,  3.    ,  0.    , ...,  0.    ,  7.925 ,  2.    ],\n",
       "       ...,\n",
       "       [ 0.    ,  3.    ,  0.    , ...,  2.    , 23.45  ,  2.    ],\n",
       "       [ 1.    ,  1.    ,  1.    , ...,  0.    , 30.    ,  0.    ],\n",
       "       [ 0.    ,  3.    ,  1.    , ...,  0.    ,  7.75  ,  1.    ]])"
      ]
     },
     "execution_count": 42,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "selected_data_numpy = selected_data.values\n",
    "selected_data_numpy"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 43,
   "metadata": {},
   "outputs": [],
   "source": [
    "x_data = selected_data_numpy[:,1:]\n",
    "y_data = selected_data_numpy[:,0]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 44,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "array([[1., 0.],\n",
       "       [0., 1.],\n",
       "       [0., 1.],\n",
       "       ...,\n",
       "       [1., 0.],\n",
       "       [0., 1.],\n",
       "       [1., 0.]], dtype=float32)"
      ]
     },
     "execution_count": 44,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "import tensorflow as tf\n",
    "y_data = tf.one_hot(y_data,depth=2)\n",
    "y_data = y_data.numpy()\n",
    "y_data"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 45,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "(891, 2)"
      ]
     },
     "execution_count": 45,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "y_data.shape"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 46,
   "metadata": {},
   "outputs": [],
   "source": [
    "from sklearn import preprocessing \n",
    "Scaler = preprocessing.MinMaxScaler(feature_range=(0,1))\n",
    "scaled_x_data = Scaler.fit_transform(x_data)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 47,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "array([[1.        , 1.        , 0.27117366, ..., 0.        , 0.01415106,\n",
       "        1.        ],\n",
       "       [0.        , 0.        , 0.4722292 , ..., 0.        , 0.13913574,\n",
       "        0.        ],\n",
       "       [1.        , 0.        , 0.32143755, ..., 0.        , 0.01546857,\n",
       "        1.        ],\n",
       "       ...,\n",
       "       [1.        , 0.        , 0.36792055, ..., 0.33333333, 0.04577135,\n",
       "        1.        ],\n",
       "       [0.        , 1.        , 0.32143755, ..., 0.        , 0.0585561 ,\n",
       "        0.        ],\n",
       "       [1.        , 1.        , 0.39683338, ..., 0.        , 0.01512699,\n",
       "        0.5       ]])"
      ]
     },
     "execution_count": 47,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "scaled_x_data"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 49,
   "metadata": {},
   "outputs": [],
   "source": [
    "model = tf.keras.models.Sequential()\n",
    "model.add(tf.keras.layers.Dense(units = 64,\n",
    "                               input_dim = 7,\n",
    "                               use_bias = True,\n",
    "                               kernel_initializer = \"uniform\",\n",
    "                               bias_initializer = \"zeros\",\n",
    "                               activation = \"relu\"))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 50,
   "metadata": {},
   "outputs": [],
   "source": [
    "model.add(tf.keras.layers.Dense(units = 32,\n",
    "                               activation = \"sigmoid\"))\n",
    "model.add(tf.keras.layers.Dense(units = 2,\n",
    "                               activation = \"softmax\"))\n",
    "model.compile(optimizer=tf.keras.optimizers.Adam(0.003),\n",
    "             loss = \"categorical_crossentropy\",\n",
    "             metrics=[\"accuracy\"])"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 51,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Epoch 1/100\n",
      "18/18 - 0s - loss: 0.6740 - accuracy: 0.6011 - val_loss: 0.5621 - val_accuracy: 0.7486\n",
      "Epoch 2/100\n",
      "18/18 - 0s - loss: 0.6129 - accuracy: 0.6798 - val_loss: 0.5368 - val_accuracy: 0.7318\n",
      "Epoch 3/100\n",
      "18/18 - 0s - loss: 0.6073 - accuracy: 0.6812 - val_loss: 0.5262 - val_accuracy: 0.7486\n",
      "Epoch 4/100\n",
      "18/18 - 0s - loss: 0.6070 - accuracy: 0.6784 - val_loss: 0.5510 - val_accuracy: 0.7486\n",
      "Epoch 5/100\n",
      "18/18 - 0s - loss: 0.5883 - accuracy: 0.7051 - val_loss: 0.5136 - val_accuracy: 0.7654\n",
      "Epoch 6/100\n",
      "18/18 - 0s - loss: 0.5700 - accuracy: 0.7093 - val_loss: 0.4879 - val_accuracy: 0.8045\n",
      "Epoch 7/100\n",
      "18/18 - 0s - loss: 0.5550 - accuracy: 0.7121 - val_loss: 0.4635 - val_accuracy: 0.7933\n",
      "Epoch 8/100\n",
      "18/18 - 0s - loss: 0.5311 - accuracy: 0.7388 - val_loss: 0.4370 - val_accuracy: 0.8101\n",
      "Epoch 9/100\n",
      "18/18 - 0s - loss: 0.5243 - accuracy: 0.7458 - val_loss: 0.4240 - val_accuracy: 0.7933\n",
      "Epoch 10/100\n",
      "18/18 - 0s - loss: 0.5157 - accuracy: 0.7514 - val_loss: 0.4301 - val_accuracy: 0.8212\n",
      "Epoch 11/100\n",
      "18/18 - 0s - loss: 0.4948 - accuracy: 0.7725 - val_loss: 0.4052 - val_accuracy: 0.8101\n",
      "Epoch 12/100\n",
      "18/18 - 0s - loss: 0.4820 - accuracy: 0.7865 - val_loss: 0.4137 - val_accuracy: 0.8324\n",
      "Epoch 13/100\n",
      "18/18 - 0s - loss: 0.4877 - accuracy: 0.7669 - val_loss: 0.3863 - val_accuracy: 0.8101\n",
      "Epoch 14/100\n",
      "18/18 - 0s - loss: 0.4981 - accuracy: 0.7823 - val_loss: 0.4031 - val_accuracy: 0.8324\n",
      "Epoch 15/100\n",
      "18/18 - 0s - loss: 0.4710 - accuracy: 0.7795 - val_loss: 0.3781 - val_accuracy: 0.8212\n",
      "Epoch 16/100\n",
      "18/18 - 0s - loss: 0.4685 - accuracy: 0.7865 - val_loss: 0.3804 - val_accuracy: 0.8659\n",
      "Epoch 17/100\n",
      "18/18 - 0s - loss: 0.4685 - accuracy: 0.7893 - val_loss: 0.3673 - val_accuracy: 0.8492\n",
      "Epoch 18/100\n",
      "18/18 - 0s - loss: 0.4638 - accuracy: 0.7879 - val_loss: 0.3727 - val_accuracy: 0.8603\n",
      "Epoch 19/100\n",
      "18/18 - 0s - loss: 0.4579 - accuracy: 0.7893 - val_loss: 0.3521 - val_accuracy: 0.8492\n",
      "Epoch 20/100\n",
      "18/18 - 0s - loss: 0.4674 - accuracy: 0.7907 - val_loss: 0.3908 - val_accuracy: 0.8603\n",
      "Epoch 21/100\n",
      "18/18 - 0s - loss: 0.4790 - accuracy: 0.7795 - val_loss: 0.3647 - val_accuracy: 0.8436\n",
      "Epoch 22/100\n",
      "18/18 - 0s - loss: 0.4595 - accuracy: 0.7907 - val_loss: 0.3699 - val_accuracy: 0.8603\n",
      "Epoch 23/100\n",
      "18/18 - 0s - loss: 0.4576 - accuracy: 0.7893 - val_loss: 0.3514 - val_accuracy: 0.8492\n",
      "Epoch 24/100\n",
      "18/18 - 0s - loss: 0.4579 - accuracy: 0.7992 - val_loss: 0.3570 - val_accuracy: 0.8547\n",
      "Epoch 25/100\n",
      "18/18 - 0s - loss: 0.4525 - accuracy: 0.7879 - val_loss: 0.3500 - val_accuracy: 0.8603\n",
      "Epoch 26/100\n",
      "18/18 - 0s - loss: 0.4476 - accuracy: 0.7992 - val_loss: 0.3475 - val_accuracy: 0.8715\n",
      "Epoch 27/100\n",
      "18/18 - 0s - loss: 0.4435 - accuracy: 0.7978 - val_loss: 0.3399 - val_accuracy: 0.8659\n",
      "Epoch 28/100\n",
      "18/18 - 0s - loss: 0.4785 - accuracy: 0.7865 - val_loss: 0.3677 - val_accuracy: 0.8492\n",
      "Epoch 29/100\n",
      "18/18 - 0s - loss: 0.4653 - accuracy: 0.7879 - val_loss: 0.3539 - val_accuracy: 0.8547\n",
      "Epoch 30/100\n",
      "18/18 - 0s - loss: 0.4512 - accuracy: 0.8118 - val_loss: 0.3621 - val_accuracy: 0.8436\n",
      "Epoch 31/100\n",
      "18/18 - 0s - loss: 0.4496 - accuracy: 0.8062 - val_loss: 0.3562 - val_accuracy: 0.8380\n",
      "Epoch 32/100\n",
      "18/18 - 0s - loss: 0.4627 - accuracy: 0.7935 - val_loss: 0.3438 - val_accuracy: 0.8715\n",
      "Epoch 33/100\n",
      "18/18 - 0s - loss: 0.4516 - accuracy: 0.8048 - val_loss: 0.3640 - val_accuracy: 0.8436\n",
      "Epoch 34/100\n",
      "18/18 - 0s - loss: 0.4483 - accuracy: 0.8048 - val_loss: 0.3518 - val_accuracy: 0.8659\n",
      "Epoch 35/100\n",
      "18/18 - 0s - loss: 0.4433 - accuracy: 0.8132 - val_loss: 0.3505 - val_accuracy: 0.8436\n",
      "Epoch 36/100\n",
      "18/18 - 0s - loss: 0.4424 - accuracy: 0.8006 - val_loss: 0.3389 - val_accuracy: 0.8659\n",
      "Epoch 37/100\n",
      "18/18 - 0s - loss: 0.4332 - accuracy: 0.8104 - val_loss: 0.3283 - val_accuracy: 0.8547\n",
      "Epoch 38/100\n",
      "18/18 - 0s - loss: 0.4355 - accuracy: 0.8146 - val_loss: 0.3380 - val_accuracy: 0.8603\n",
      "Epoch 39/100\n",
      "18/18 - 0s - loss: 0.4335 - accuracy: 0.8034 - val_loss: 0.3284 - val_accuracy: 0.8603\n",
      "Epoch 40/100\n",
      "18/18 - 0s - loss: 0.4349 - accuracy: 0.8034 - val_loss: 0.3611 - val_accuracy: 0.8603\n",
      "Epoch 41/100\n",
      "18/18 - 0s - loss: 0.4503 - accuracy: 0.8020 - val_loss: 0.3382 - val_accuracy: 0.8659\n",
      "Epoch 42/100\n",
      "18/18 - 0s - loss: 0.4366 - accuracy: 0.7949 - val_loss: 0.3470 - val_accuracy: 0.8436\n",
      "Epoch 43/100\n",
      "18/18 - 0s - loss: 0.4376 - accuracy: 0.8006 - val_loss: 0.3347 - val_accuracy: 0.8603\n",
      "Epoch 44/100\n",
      "18/18 - 0s - loss: 0.4362 - accuracy: 0.8006 - val_loss: 0.3269 - val_accuracy: 0.8603\n",
      "Epoch 45/100\n",
      "18/18 - 0s - loss: 0.4268 - accuracy: 0.8118 - val_loss: 0.3257 - val_accuracy: 0.8603\n",
      "Epoch 46/100\n",
      "18/18 - 0s - loss: 0.4421 - accuracy: 0.8076 - val_loss: 0.3586 - val_accuracy: 0.8436\n",
      "Epoch 47/100\n",
      "18/18 - 0s - loss: 0.4485 - accuracy: 0.8006 - val_loss: 0.3204 - val_accuracy: 0.8492\n",
      "Epoch 48/100\n",
      "18/18 - 0s - loss: 0.4410 - accuracy: 0.7879 - val_loss: 0.3584 - val_accuracy: 0.8380\n",
      "Epoch 49/100\n",
      "18/18 - 0s - loss: 0.4465 - accuracy: 0.8076 - val_loss: 0.3221 - val_accuracy: 0.8547\n",
      "Epoch 50/100\n",
      "18/18 - 0s - loss: 0.4279 - accuracy: 0.8090 - val_loss: 0.3236 - val_accuracy: 0.8436\n",
      "Epoch 51/100\n",
      "18/18 - 0s - loss: 0.4290 - accuracy: 0.8048 - val_loss: 0.3312 - val_accuracy: 0.8603\n",
      "Epoch 52/100\n",
      "18/18 - 0s - loss: 0.4282 - accuracy: 0.8104 - val_loss: 0.3181 - val_accuracy: 0.8547\n",
      "Epoch 53/100\n",
      "18/18 - 0s - loss: 0.4416 - accuracy: 0.7935 - val_loss: 0.3531 - val_accuracy: 0.8492\n",
      "Epoch 54/100\n",
      "18/18 - 0s - loss: 0.4504 - accuracy: 0.7992 - val_loss: 0.3282 - val_accuracy: 0.8547\n",
      "Epoch 55/100\n",
      "18/18 - 0s - loss: 0.4337 - accuracy: 0.7949 - val_loss: 0.3370 - val_accuracy: 0.8436\n",
      "Epoch 56/100\n",
      "18/18 - 0s - loss: 0.4220 - accuracy: 0.8160 - val_loss: 0.3209 - val_accuracy: 0.8603\n",
      "Epoch 57/100\n",
      "18/18 - 0s - loss: 0.4225 - accuracy: 0.8132 - val_loss: 0.3304 - val_accuracy: 0.8603\n",
      "Epoch 58/100\n",
      "18/18 - 0s - loss: 0.4277 - accuracy: 0.8090 - val_loss: 0.3196 - val_accuracy: 0.8547\n",
      "Epoch 59/100\n",
      "18/18 - 0s - loss: 0.4277 - accuracy: 0.8118 - val_loss: 0.3274 - val_accuracy: 0.8492\n",
      "Epoch 60/100\n",
      "18/18 - 0s - loss: 0.4203 - accuracy: 0.8188 - val_loss: 0.3176 - val_accuracy: 0.8547\n",
      "Epoch 61/100\n",
      "18/18 - 0s - loss: 0.4220 - accuracy: 0.8146 - val_loss: 0.3229 - val_accuracy: 0.8603\n",
      "Epoch 62/100\n",
      "18/18 - 0s - loss: 0.4334 - accuracy: 0.8076 - val_loss: 0.3331 - val_accuracy: 0.8603\n",
      "Epoch 63/100\n",
      "18/18 - 0s - loss: 0.4206 - accuracy: 0.8230 - val_loss: 0.3186 - val_accuracy: 0.8547\n",
      "Epoch 64/100\n",
      "18/18 - 0s - loss: 0.4194 - accuracy: 0.8174 - val_loss: 0.3360 - val_accuracy: 0.8547\n",
      "Epoch 65/100\n",
      "18/18 - 0s - loss: 0.4228 - accuracy: 0.8104 - val_loss: 0.3680 - val_accuracy: 0.8436\n",
      "Epoch 66/100\n",
      "18/18 - 0s - loss: 0.4317 - accuracy: 0.8076 - val_loss: 0.3462 - val_accuracy: 0.8547\n",
      "Epoch 67/100\n",
      "18/18 - 0s - loss: 0.4433 - accuracy: 0.8104 - val_loss: 0.3394 - val_accuracy: 0.8603\n",
      "Epoch 68/100\n",
      "18/18 - 0s - loss: 0.4395 - accuracy: 0.7978 - val_loss: 0.3339 - val_accuracy: 0.8547\n",
      "Epoch 69/100\n",
      "18/18 - 0s - loss: 0.4133 - accuracy: 0.8216 - val_loss: 0.3286 - val_accuracy: 0.8436\n",
      "Epoch 70/100\n",
      "18/18 - 0s - loss: 0.4176 - accuracy: 0.8118 - val_loss: 0.3420 - val_accuracy: 0.8603\n",
      "Epoch 71/100\n",
      "18/18 - 0s - loss: 0.4212 - accuracy: 0.8076 - val_loss: 0.3155 - val_accuracy: 0.8547\n",
      "Epoch 72/100\n",
      "18/18 - 0s - loss: 0.4157 - accuracy: 0.8174 - val_loss: 0.3265 - val_accuracy: 0.8603\n",
      "Epoch 73/100\n",
      "18/18 - 0s - loss: 0.4156 - accuracy: 0.8188 - val_loss: 0.3307 - val_accuracy: 0.8659\n",
      "Epoch 74/100\n",
      "18/18 - 0s - loss: 0.4149 - accuracy: 0.8188 - val_loss: 0.3471 - val_accuracy: 0.8436\n",
      "Epoch 75/100\n",
      "18/18 - 0s - loss: 0.4257 - accuracy: 0.8104 - val_loss: 0.3173 - val_accuracy: 0.8659\n",
      "Epoch 76/100\n",
      "18/18 - 0s - loss: 0.4195 - accuracy: 0.8132 - val_loss: 0.3312 - val_accuracy: 0.8547\n",
      "Epoch 77/100\n",
      "18/18 - 0s - loss: 0.4227 - accuracy: 0.8118 - val_loss: 0.3142 - val_accuracy: 0.8547\n",
      "Epoch 78/100\n",
      "18/18 - 0s - loss: 0.4164 - accuracy: 0.8202 - val_loss: 0.3352 - val_accuracy: 0.8436\n",
      "Epoch 79/100\n",
      "18/18 - 0s - loss: 0.4094 - accuracy: 0.8160 - val_loss: 0.3315 - val_accuracy: 0.8603\n",
      "Epoch 80/100\n",
      "18/18 - 0s - loss: 0.4337 - accuracy: 0.8020 - val_loss: 0.3849 - val_accuracy: 0.8436\n",
      "Epoch 81/100\n",
      "18/18 - 0s - loss: 0.4290 - accuracy: 0.8118 - val_loss: 0.3257 - val_accuracy: 0.8659\n",
      "Epoch 82/100\n",
      "18/18 - 0s - loss: 0.4194 - accuracy: 0.8090 - val_loss: 0.3366 - val_accuracy: 0.8659\n",
      "Epoch 83/100\n",
      "18/18 - 0s - loss: 0.4215 - accuracy: 0.8202 - val_loss: 0.3199 - val_accuracy: 0.8603\n"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Epoch 84/100\n",
      "18/18 - 0s - loss: 0.4168 - accuracy: 0.8132 - val_loss: 0.3306 - val_accuracy: 0.8603\n",
      "Epoch 85/100\n",
      "18/18 - 0s - loss: 0.4256 - accuracy: 0.8076 - val_loss: 0.3282 - val_accuracy: 0.8659\n",
      "Epoch 86/100\n",
      "18/18 - 0s - loss: 0.4131 - accuracy: 0.8216 - val_loss: 0.3222 - val_accuracy: 0.8380\n",
      "Epoch 87/100\n",
      "18/18 - 0s - loss: 0.4181 - accuracy: 0.8188 - val_loss: 0.3131 - val_accuracy: 0.8436\n",
      "Epoch 88/100\n",
      "18/18 - 0s - loss: 0.4217 - accuracy: 0.8174 - val_loss: 0.3196 - val_accuracy: 0.8659\n",
      "Epoch 89/100\n",
      "18/18 - 0s - loss: 0.4278 - accuracy: 0.7963 - val_loss: 0.3190 - val_accuracy: 0.8659\n",
      "Epoch 90/100\n",
      "18/18 - 0s - loss: 0.4341 - accuracy: 0.8062 - val_loss: 0.3159 - val_accuracy: 0.8771\n",
      "Epoch 91/100\n",
      "18/18 - 0s - loss: 0.4293 - accuracy: 0.8048 - val_loss: 0.3361 - val_accuracy: 0.8659\n",
      "Epoch 92/100\n",
      "18/18 - 0s - loss: 0.4152 - accuracy: 0.8216 - val_loss: 0.3233 - val_accuracy: 0.8603\n",
      "Epoch 93/100\n",
      "18/18 - 0s - loss: 0.4084 - accuracy: 0.8146 - val_loss: 0.3251 - val_accuracy: 0.8603\n",
      "Epoch 94/100\n",
      "18/18 - 0s - loss: 0.4090 - accuracy: 0.8244 - val_loss: 0.3174 - val_accuracy: 0.8659\n",
      "Epoch 95/100\n",
      "18/18 - 0s - loss: 0.4124 - accuracy: 0.8202 - val_loss: 0.3308 - val_accuracy: 0.8715\n",
      "Epoch 96/100\n",
      "18/18 - 0s - loss: 0.4182 - accuracy: 0.8174 - val_loss: 0.3224 - val_accuracy: 0.8715\n",
      "Epoch 97/100\n",
      "18/18 - 0s - loss: 0.4071 - accuracy: 0.8272 - val_loss: 0.3191 - val_accuracy: 0.8492\n",
      "Epoch 98/100\n",
      "18/18 - 0s - loss: 0.4079 - accuracy: 0.8174 - val_loss: 0.3413 - val_accuracy: 0.8492\n",
      "Epoch 99/100\n",
      "18/18 - 0s - loss: 0.4151 - accuracy: 0.8216 - val_loss: 0.3559 - val_accuracy: 0.8603\n",
      "Epoch 100/100\n",
      "18/18 - 0s - loss: 0.4143 - accuracy: 0.8272 - val_loss: 0.3637 - val_accuracy: 0.8436\n"
     ]
    }
   ],
   "source": [
    "train_history = model.fit(x_data,y_data,validation_split=0.2,epochs=100,batch_size = 40,verbose = 2)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.7.7"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 4
}
